package com.neu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neu.mapper.CheckinMapper;
import com.neu.mapper.CheckoutMapper;
import com.neu.mapper.FeetypeMapper;
import com.neu.po.Feetype;
import com.neu.po.FeetypeExample;
import com.neu.vo.CheckinAndCheckout;
@Service
public class CheckoutServiceImpl implements CheckoutService {
	
	@Autowired
	private FeetypeMapper feetypeMapper;
	
	@Autowired
	private CheckoutMapper checkoutMapper;
	
	@Autowired
	private CheckinMapper checkinMapper;
	//得到所有付款方式
	@Override
	public List<Feetype> getAll() {
		FeetypeExample exampl= new FeetypeExample();
		return feetypeMapper.selectByExample(exampl);
	}
	
	//退房插入
	@Override
	@Transactional
	public int insertAndUpdate( CheckinAndCheckout stp  ) {
		
		 int a =checkoutMapper.insert(stp.getOut());
		 int b = checkinMapper.updateByPrimaryKey(stp.getUpdat());
		 
		 if(a == 1 && b ==1) {
			 return 1;
		 }
		 return 0;
	}

}
